<?php
/**
 * Enter description here...
 *
 */
class HPageAdmin {
	function addModuleToPage($module_instance_id, $page_id, $pane = 'ContentPane', $position = '99999', $align = 'center', $created_date = null, $created_user = null, $modified_date= null, $modified_user= null) {
		try{
			HSql::doQuery("INSERT INTO portal_pages_modules (page_id, module_instance_id, pane_name, position, alignment, created_date, created_user, modified_date, modified_user)
							VALUES ('".$page_id."','".$module_instance_id."','".$pane."', '".$position."', '".$align."','".$created_date."','".$created_user."','".$modified_date."','".$modified_user."')");
		}
		catch (Exception $ex){
			throw new $ex->getMessage();
		}
	}
	
	function deleteModuleFromPage($module_instance_id, $page_id){
		try {
			HSql::doQuery("DELETE FROM 	portal_pages_modules 
								WHERE 	module_instance_id ='".$module_instance_id."' 
								AND 	page_id='".$page_id."'");
		}
		catch (Exception $ex){
			throw new Exception($ex->getMessage());
		}
	}
	
	function insertPage($portal_id, $page_alias, $page_title = null,  $keyword = null, $description = null, $parent_id = null, $url_alias = null, $position='99999', $layout_name='default', $created_date = null, $created_user = null, $modified_date = null, $modified_user= null){
		try {
			HSql::doQuery("INSERT INTO portal_pages (portal_id,  page_alias, page_title, keyword, description, parent_id, url_alias, position, layout_name, created_date, created_user, modified_date, modified_user) 
						VALUES ('".$portal_id."','".$page_alias."','".$page_title."','".$keyword."','".$description."','".$parent_id."','".$url_alias."','".$position."','".$layout_name."','".$created_date."','".$created_user."','".$modified_date."','".$created_user."')");
		}
		catch (Exception $ex){
			throw new Exception($ex->getMessage());
		}
	}
	
	public function updatePage($page_id, $portal_id, $page_alias, $page_title = null,  $keyword = null, $description = null, $parent_id = null, $url_alias = null, $position='99999', $layout_name='default', $modified_date = null, $modified_user= null){
		try {
			HSql::doQuery("UPDATE portal_pages SET portal_id 	= '".$portal_id."',
													page_alias	= '".$page_alias."',
													page_title	= '".$page_title."',
													keyword		= '".$keyword."',
													description	= '".$description."',
													parent_id	= '".$page_id."',
													url_alias	= '".$url_alias."',
													position	= '".$position."',
													layout_name	= '".$layout_name."',
													modified_date= '".$modified_date."',
													modified_user= '".$modified_user."'
													
												WHERE id ='".$page_id."'");
		}
		catch (Exception $ex){
			throw new $ex->getMessage();
		}
	}
	
	public function deletePage($page_id){
		try {
			HSql::doQuery("DELETE FROM portal_pages WHERE id ='".$page_id."'");	
		}
		catch (Exception $ex){
			throw new ErrorException($ex->getMessage());
		}
		
	}
}

?>